<%@ page contentType="text/html;charset=utf-8" language="java"
	pageEncoding="UTF-8" import="java.util.Date"%>
<!DOCTYPE html>
<html lang="en">
  <head>
     
    <meta charset="utf-8">
    <title>产品研发系统</title>
     <%@include file="/WEB-INF/jsp/common/style.jsp"%>

	<c:set var="ctx" value="${pageContext.request.contextPath}"/>
	<script type="text/javascript">
		var basePath = "${ctx}";
	</script>
    <link href="${ctx}/css/jquery.treeview.css" rel="stylesheet">
    
    <link rel="Favicon Icon" href="favicon.ico">
   <script type="text/javascript" src="${ctx}/js/jquery.min.js"></script>
    <script src="${ctx}/js/jquery.treeview.js" type="text/javascript"> </script>
     <script type="text/javascript">
	$(document).ready(function(){
		$("#tree1").treeview(); 
		  $("#tree").treeview({  
	        	//collapsed: true  
    			});  
	});
	function modify(id){
		edit(id);
	}
	</script>
     
  </head>
  <body>
   <div id="wrap">
    
	<form class="form-horizontal"  id="seachform" action="${pageContext.request.contextPath}/set/category/index"	method="post">
	 <div   class="container-fluid" style="padding-top:30px;padding-left:30px">
     
      <!-- Main window -->
      <div class="main_container" id="dashboard_page">

		 <div class="row-fluid">
      	 	<div>   
               <input class="btn btn-primary buttonrole" type="button"  name="btnadd" value="新增" onclick="edit('')">
               
            </div>
		</div>
		
		<div class="row-fluid">
	  		<ul id="tree" class="filetree">
		        <li><span class="folder">商品品类</span>
		        	<ul>
		        	<c:forEach items="${model.items}" var="item" varStatus="itemStatus">        
		                   <li><span class="folder" ondblclick="modify('${item.currentCategory.id}')">${item.currentCategory.categoryLevel}、${item.currentCategory.categoryName}<a style="padding-left:5px"  class="buttonrole"  name="btndel" href="javascript:del('${item.currentCategory.id}')">删除</a></span>  
		                   <c:if test="${item.isHasChild==1}">
		                   		<ul>
		                   			<c:forEach items="${item.childCategory}" var="item2" varStatus="itemStatus">     
		                   				 <li><span class="folder"  ondblclick="modify('${item2.currentCategory.id}')">${item2.currentCategory.categoryLevel}、${item2.currentCategory.categoryName}<a style="padding-left:5px" class="buttonrole"  name="btndel" href="javascript:del('${item2.currentCategory.id}')">删除</a></span>
		                   				 	 <c:if test="${item2.isHasChild==1}">
		                   				 	 	<ul>
		                   				 	 		<c:forEach items="${item2.childCategory}" var="item3" varStatus="itemStatus">   
		                   				 	 			 <li><span class="folder"  ondblclick="modify('${item3.currentCategory.id}')">${item3.currentCategory.categoryLevel}、${item3.currentCategory.categoryName}<a style="padding-left:5px"  class="buttonrole"  name="btndel" href="javascript:del('${item3.currentCategory.id}')">删除</a></span> 
		                   				 	 		</c:forEach>
												</ul>
		                   				 	 </c:if>
		                   				 </li>   
		                   			</c:forEach>
		                   		</ul>
		                   </c:if>   
		                   </li>       
			        </c:forEach>
		         </ul>
				</li>
		    </ul>
    	</div>
    </div>
    </div>
    </form>
    </div>
   </body>
     <script type="text/javascript">
	function seach(){
		$("#cpage").val(1);
		oksubmit();
	}
	function oksubmit() {
	    $("#btnOk").attr("disabled", "disabled");	  
	    var objform = document.getElementById('seachform');
	    objform.submit();
	}	
	function del(id){		
		layer.confirm('确认要删除此分类吗', {
			  btn: ['确认','取消'] //按钮
			}, function(){
				layer.closeAll();
				sendOpTo(id);
			}, function(){
			  
			});			
	}
	function sendOpTo(id){
		layer.load(1, {shade: [0.5,'#fff']});
		var postData="categoryId=" + id;
		//alert(postData);
		 $.ajax({
	            type: "POST",
	            url: "del",
	            data: postData,
	            contentType: "application/x-www-form-urlencoded;charset=UTF-8",
	            async: true, // 同步  true 异步。默认是异步
	            dataType: 'json',
	            error: function(resultdata) {
	            	layer.closeAll();
	            },
	            success: function(resultdata) {
	            	layer.closeAll();
	                if(resultdata.returnCode=="0000"){               	
	                	layer.alert('操作成功',{icon: 1}, function(){
	                		layer.closeAll();
	                	 	 oksubmit();
	                	});
	                }else{
	                	layer.alert(resultdata.returnMessage);
	                }
	            }
	        });
	}
	
    function editReturn() {
       layer.closeAll();
       oksubmit();
    }
    function closeAll() {
        layer.closeAll();
     }
    function edit(id){
		var domainUrl="edit?categoryId=" + id;
		layer.open({
			  type: 2,
			  title: '品类',
			   area: ['600px', '520px'],
			   content: domainUrl //iframe的url
			 }); 
	}
	
	</script>
</html>
